Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dynamic font support /font/<name>/<start>-<end> #755

Merged
merged 10 commits into from
Oct 28, 2023

Conversation

nyurik
Copy link
Member

@nyurik nyurik commented Jul 9, 2023

This implements dynamic font protobuf generation, allowing users to request font ranges on the fly, and combining them in any order, e.g. Font1,Font2,Font3, same as with sprites and tiles

This is a first iteration, without any multithreading support. In theory, this could be done far faster by generating SDFs with multiple threads.

Current process

  • during init, figure out all glyphs available in each font, and store them as a bitset
  • during request:
    • combine requested bitsets to figure out which glyph should come from which font file
    • load those glyphs from files (using a single instance of the freetype lib)
    • convert them to SDFs and package them into a protobuf

Copy link
Member

@lseelenbinder lseelenbinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor things / nits, but otherwise solid.

martin/src/fonts/mod.rs Outdated Show resolved Hide resolved
martin/src/fonts/mod.rs Outdated Show resolved Hide resolved
@sharkAndshark
Copy link
Collaborator

This feature is what I looking forward 🤩

@nyurik
Copy link
Member Author

nyurik commented Oct 17, 2023

Want to make a test or some docs?

@sharkAndshark
Copy link
Collaborator

Want to make a test or some docs?

Sure :D

@sharkAndshark
Copy link
Collaborator

sharkAndshark commented Oct 24, 2023

Open Source Fonts Resources For Tests:

License Feature
source-han-sans license Japanese&Chinese
RedHat Overpass SIL1.1 English fonts

I believe we can use these two fonts for tests and my concern is the font file size, maybe we should download them in CI instead of include them in repo?

@sharkAndshark sharkAndshark mentioned this pull request Oct 24, 2023
@sharkAndshark
Copy link
Collaborator

Hi @nyurik Have a lovely day : )
For doc about font feature, I submitted a PR here.

@sharkAndshark
Copy link
Collaborator

I add font test in test.sh in this PR

This will NOT compile until stadiamaps/sdf_font_tools#13 is merged and published

This implements dynamic font protobuf generation, allowing users to request font ranges on the fly, and combining them in any order, e.g. `Font1,Font2,Font3`, same as with sprites and tiles

This is a first iteration, without any multithreading support. In theory, this could be done far faster by generating SDFs with multiple threads.

Current steps:
* during init, figure out all glyphs available in each font, and store them as a bitset
* during request:
  * combine requested bitsets to figure out which glyph should come from which font file
  * load those glyphs from files (using a single instance of the freetype lib)
  * convert them to SDFs and package them into a protobuf
@nyurik nyurik enabled auto-merge (squash) October 28, 2023 04:49
@nyurik nyurik merged commit 9b112ae into maplibre:main Oct 28, 2023
14 of 16 checks passed
@nyurik nyurik deleted the fonts branch October 28, 2023 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants